package cn.clouds234.base64demo;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * 验证base64加解密
 *
 * @author wyf
 * @date 2023/7/27 9:40
 */
public class Base64Demo {
    public static void main(String[] args) {
        String pw = "1Qaz@wsx";
        String encodeToString = Base64.getEncoder().encodeToString(pw.getBytes(StandardCharsets.UTF_8));
        String decode = new String(Base64.getDecoder().decode(encodeToString), StandardCharsets.UTF_8);
        String decode2 = new String(Base64.getDecoder().decode("MVFhekB3c3g"), StandardCharsets.UTF_8);
        String decode1 = Base64.getDecoder().decode(encodeToString).toString();
        System.out.println(encodeToString);
        System.out.println(decode);
        System.out.println(decode1);
        System.out.println(decode2);


    }
}
